package com.kanshu.ksgb.fastread.doudou.module.personal.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.common.view.CustomDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by xubo on 18/10/21
 */
public class SignBindPhoneDialog extends Dialog {
    @BindView(R.id.desc)
    TextView mDesc;
    CustomDialog.Callback mCallback;
    public void setCallback(CustomDialog.Callback callback) {
        mCallback = callback;
    }

    public SignBindPhoneDialog(@NonNull Context context) {
        super(context, R.style.dialog_style);
        init();
    }

    public SignBindPhoneDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        init();
    }

    protected SignBindPhoneDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        init();
    }

    private void init() {
        setContentView(R.layout.dialog_sign_bind_phone);
        ButterKnife.bind(this);
    }

    public void setContent(CharSequence s) {
        mDesc.setText(s);
    }

    @OnClick({R.id.bind_phone, R.id.bind_phone_message, R.id.close})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.close:
                dismiss();
                break;
            case R.id.bind_phone:
            case R.id.bind_phone_message:
                if (mCallback != null) {
                    mCallback.onSure(this);
                }
                dismiss();
                break;
        }
    }

    public static SignBindPhoneDialog show(Activity activity, CharSequence content, CustomDialog.Callback callback) {
        if (activity == null || activity.isFinishing()) {
            return null;
        }
        final SignBindPhoneDialog dlg = new SignBindPhoneDialog(activity);
        dlg.setCallback(callback);
        dlg.show();
        return dlg;
    }
}
